/**
 * 正则扩展-命名捕获
 */

let str = '<a href="http:www.baidu.com">百度</a>';

// 提取url与标签文本
/* const reg = /<a href="(.*)">(.*)<\/a>/;

const result = reg.exec(str);
console.log(result); */

// 命名捕获
const reg = /<a href="(?<url>.*)">(?<text>.*)<\/a>/;
const result = reg.exec(str);

console.log(result.groups.url);
console.log(result.groups.text);
